<#include "admin/common/include/sysparam.html">

<div class="row-fluid">
	<div class="span12">
		<!-- BEGIN EXTRAS PORTLET-->
		<div class="portlet box">
			<div class="portlet-title">
				<div class="caption">
					<h5>内容编辑</h5>
				</div>
			</div>
			<div class="portlet-body form">
				<div class="alert alert-error " id="errtip" style="display: none;"></div>

				<!-- BEGIN FORM-->
				<form action="${contextPath}/Admin-Banner-save.action"
					id="bannerAddForm" class="form-horizontal" method="post">
					<input type="hidden" name="id" value="${(bean.id)?if_exists}" />
					<div class="control-group">
						<label class="control-label">组key<span class="required">*</span></label>
						<div class="controls"><@select paramCode=groupKeyCode
							value=(bean.groupKey)?if_exists item=' name="groupKey"
							require="true" datatype="require" msg="组key不能为空"'/></div>
					</div>
					<div class="control-group">
						<label class="control-label">栏目名称<span class="required">*</span></label>
						<div class="controls">
							<input type="text" name="name" id="name" require="true"
								datatype="require" msg="栏目名称不能为空" class="span3 m-wrap"
								value="${(bean.name)?if_exists}" />
						</div>
					</div>

					<div class="control-group">
						<label class="control-label">栏目图片</label>
						<div class="controls">
								<#if bean?? && bean.imageUrl ?? > <img
									src="${contextPath}${(bean.imageUrl)?if_exists}"  width="250"
								height="250" id="imgShow" alt="Photo" /> <#else> <img
									src="${contextPath}/common/image/default-pic.png"  width="250"
								height="250" id="imgShow" /> </#if>  
							 
						</div>
					</div>
					<div class="control-group">
						<label class="control-label"></label>
						<div class="controls">
							<span class="btn  fileinput-button"> <i
								class="icon-plus icon-white"></i> <span>选择文件...</span> <input
								type="file" id="upfile1" name="upfile1" />
							</span> <input type="hidden" id="imageUrl" name="imageUrl"
								value="${(bean.imageUrl)?if_exists}" /> <a class="btn start"
								onclick="uploadNavPic();"> <i class="icon-upload icon-white"></i>
								<span>上传</span>
							</a> <br> <span class="alert alert-error" id="upfile1_error_tip"
								style="display: none;"></span>
							<div class="alert alert-success" id="upfile1_detail"
								style="display: none;">
								<div class="fileName">
									文件名称:<span></span>
								</div>
								<div class="fileSize">
									文件大小:<span></span>
								</div>
							</div>

						</div>
					</div>
					<div class="control-group">
						<label class="control-label">链接类型&nbsp;&nbsp;</label>
						<div class="controls">
							<@select paramCode=blockLinkType
							value=(bean.linkType)?if_exists item=' name="linkType" require="true"
							datatype="require" msg="链接类型不能为空"'/>
						</div>
					</div>
					<div class="control-group">
						<label class="control-label">外链接&nbsp;&nbsp;</label>
						<div class="controls"> 
								<textarea class="span6  m-wrap" rows="2" id="linkUrl"
								name="linkUrl">${(bean.linkUrl)?if_exists}</textarea>
						</div>
					</div>
					<!-- <div class="control-group">
						<label class="control-label">模板&nbsp;&nbsp;</label>
						<div class="controls">
							<input name="template" type="text" class="span3 m-wrap"
								value="${(bean.template)?if_exists}" />
						</div>
					</div> -->
					<div class="control-group">
						<label class="control-label">排位&nbsp;&nbsp;</label>
						<div class="controls">
							<input name="rank" type="text" class="span2 m-wrap"
								value="${(bean.rank)?if_exists}" require="true"
								datatype="require" msg="排位不能为空" />
						</div>
					</div>
					<div class="control-group">
						<label class="control-label">简单描述&nbsp;&nbsp;</label>
						<div class="controls">
							<textarea class="span6  m-wrap" rows="2" id="shortDesc"
								name="shortDesc">${(bean.shortDesc)?if_exists}</textarea>
						</div>
					</div>
				 
					<div class="control-group">
						<label class="control-label">是否有效<span class="required">*</span></label>
						<div class="controls"><@select paramCode=iseffCode
							value=(bean.iseff)?if_exists item=' name="iseff" require="true"
							datatype="require" msg="是否有效不能为空"'/></div>
					</div>

					<div class="modal-footer">
						<button type="button" id="banner_save_btn" class="btn blue">保存</button>
						<button type="button" id="banner_return_btn" class="btn ">返回</button>
					</div>
				</form>

			</div>
			<!-- END EXTRAS PORTLET-->
		</div>
	</div>
</div>

<script>
	function uploadNavPic() {
		ajax.upload({
			fileEleId : 'upfile1',
			filePathId : 'imageUrl',
			successFn : function(data) {
				var isImg = /\.(gif|jpg|jpeg|png|GIF|JPG|PNG)$/
						.test(data.result.webfilePath);
				if (isImg)
					$('#imgShow').attr("src", data.result.webfilePath);
			}
		})

	}
	jQuery(document).ready(function() {
		tableAction.initSaveAction({
			formId : 'bannerAddForm',
			queryUrl : '${contextPath}/Admin-Banner-show.action',
			saveUrl : '${contextPath}/Admin-Banner-save.action',
			saveBtnId : 'banner_save_btn'
		});

		$("#banner_return_btn").bind("click", function() {
			var url = '${contextPath}/Admin-Banner-show.action';
			mainFrame.addContainer(url);
		});

		if (!jQuery.fancybox) {
			return;
		}

		if (jQuery(".fancybox-button").size() > 0) {
			jQuery(".fancybox-button").fancybox({
				groupAttr : 'data-rel',
				prevEffect : 'none',
				nextEffect : 'none',
				closeBtn : true,
				helpers : {
					title : {
						type : 'inside'
					}
				}
			});
		}
	});
</script>